<!DOCTYPE html>
<html lang="en" xmlns:layout="http://www.w3.org/1999/xhtml"
      layout:decorate="~{admin/adminJs}" xmlns:v-on="http://www.w3.org/1999/xhtml"
      xmlns:v-model="http://www.w3.org/1999/xhtml">
<body layout:fragment="content">
<div id="from">
    <el-form label-width="130px"  :model="dictionaryEntity"  ref="dictionaryEntity" :rules="rules"  style="padding: 15px;">
        <el-form-item label="字典键:" prop="dictKey" style="width: 100%">
            <el-input v-model="dictionaryEntity.dictKey" style="width: 90%;"></el-input>
        </el-form-item>
        <el-form-item label="字典值:" prop="value" style="width: 100%">
            <el-input v-model="dictionaryEntity.value" style="width: 90%;"></el-input>
        </el-form-item>
        <el-form-item label="排序:" style="width: 100%">
            <el-input-number  v-bind:controls="false" v-model="dictionaryEntity.sortNo" style="width: 90%;"></el-input-number>
        </el-form-item>
        <el-form-item label="字典代码:" prop="typeKey" style="width: 100%">
            <el-input v-model="dictionaryEntity.typeKey" style="width: 90%" readonly></el-input>
        </el-form-item>
        <el-form-item label="描述:" prop="description" style="width: 100%">
            <el-input type="textarea" v-model="dictionaryEntity.description" style="width: 90%;"></el-input>
        </el-form-item>
        <el-row style="text-align: center">
            <el-button type="primary" @click="onSubmit">保存</el-button>
            <el-button @click="resetForm('dictionaryEntity')">重置</el-button>
            <el-button @click="cancel()">取消</el-button>
        </el-row>
    </el-form>
</div>
<script>

    var id=RequestUtils.getId();

    var vm=new Vue({
        el: '#from',
        data:function () {
            var dictionaryEntity=ajaxGet("/admin/system/dictionary/entity/read",{id:id});
            dictionaryEntity.typeKey=RequestUtils.get('typeKey');
            var rules={
                dictKey:ValidateUtils.required('请输入字典键名称!'),
                value:ValidateUtils.required('请输入字典值!'),
                sortNo:ValidateUtils.required('请输入排序!'),
                typeKey:ValidateUtils.required('请输入字典代码!')
            };
            return {
                dictionaryEntity:dictionaryEntity,
                rules:rules
            };
        },
        methods:{
            onSubmit:function () {
                this.$refs['dictionaryEntity'].validate(function(valid) {
                    if (valid) {
                        EasyuiUtils.confirmSave("/admin/system/dictionary/entity/save",vm.dictionaryEntity,function () {
                            vm.closeParentDialog(true);
                        });
                    } else {
                       EasyuiUtils.alert('请输入必填项!');
                    }
                });

            },
            cancel:function () {
                vm.closeParentDialog();
            },
            closeParentDialog:function(isRefresh){
                window.parent.closeDialog(isRefresh);
            },
            resetForm:function(formName) {
                this.$refs[formName].resetFields();
            }
        }
    });
</script>

</body>
</html>